🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / service / src / androidMain / kotlin / org / meshtastic / core / service / AndroidMeshLocationManager.kt
Displaying Raw • Download
core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidMeshLocationManager.kt e85300531e124df08788c1b765d50af1bf6d516d (e8530053) Text, 3.34 KB
T8b949e/*
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.service
Tff7b72import T7ee787android.annotation.SuppressLint
Tff7b72import T7ee787android.app.Application
Tff7b72import T7ee787androidx.core.location.LocationCompat
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787kotlinx.coroutines.CoroutineScope
Tff7b72import T7ee787kotlinx.coroutines.Job
Tff7b72import T7ee787kotlinx.coroutines.flow.launchIn
Tff7b72import T7ee787kotlinx.coroutines.flow.onEach
Tff7b72import T7ee787org.koin.core.annotation.Single
Tff7b72import T7ee787org.meshtastic.core.common.hasLocationPermission
Tff7b72import T7ee787org.meshtastic.core.model.Position
Tff7b72import T7ee787org.meshtastic.core.repository.LocationRepository
Tff7b72import T7ee787org.meshtastic.core.repository.MeshLocationManager
Tff7b72import T7ee787kotlin.time.Duration.Companion.milliseconds
Tff7b72import T7ee787org.meshtastic.proto.Position Tff7b72as Te6edf3ProtoPosition
Tf0883e@Single
Tff7b72class T56d364AndroidMeshLocationManagerTb4b4b4(Tff7b72private Tff7b72val Te6edf3contextTb4b4b4: Te6edf3ApplicationTb4b4b4, Tff7b72private Tff7b72val Te6edf3locationRepositoryTb4b4b4: Te6edf3LocationRepositoryTb4b4b4) Tb4b4b4:
Te6edf3MeshLocationManager Tb4b4b4{
Tff7b72private Tff7b72lateinit Tff7b72var Te6edf3scopeTb4b4b4: Te6edf3CoroutineScope
Tff7b72private Tff7b72var Te6edf3locationFlowTb4b4b4: Te6edf3Job? Tff7b72= Tff7b72null
Tf0883e@SuppressLintTb4b4b4(Ta5d6ff"Ta5d6ffMissingPermissionTa5d6ff"Tb4b4b4)
Tff7b72override Tff7b72fun Td2a8ffstartTb4b4b4(Te6edf3scopeTb4b4b4: Te6edf3CoroutineScopeTb4b4b4, Te6edf3sendPositionFnTb4b4b4: Tb4b4b4(Te6edf3ProtoPositionTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4) Tb4b4b4{
Tff7b72thisTb4b4b4.Te6edf3scope Tff7b72= Te6edf3scope
Tff7b72if Tb4b4b4(Te6edf3locationFlowTff7b72?.Te6edf3isActive Tff7b72=Tff7b72= Tff7b72trueTb4b4b4) Tff7b72return
Tff7b72if Tb4b4b4(Te6edf3contextTb4b4b4.Te6edf3hasLocationPermissionTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3locationFlow Tff7b72=
Te6edf3locationRepository
Tb4b4b4.Te6edf3getLocationsTb4b4b4(Tb4b4b4)
Tb4b4b4.Te6edf3onEach Tb4b4b4{ Te6edf3location Tff7b72-Tff7b72>
Te6edf3sendPositionFnTb4b4b4(
Te6edf3ProtoPositionTb4b4b4(
Te6edf3latitude_i Tff7b72= Te6edf3PositionTb4b4b4.Te6edf3degITb4b4b4(Te6edf3locationTb4b4b4.Te6edf3latitudeTb4b4b4)Tb4b4b4,
Te6edf3longitude_i Tff7b72= Te6edf3PositionTb4b4b4.Te6edf3degITb4b4b4(Te6edf3locationTb4b4b4.Te6edf3longitudeTb4b4b4)Tb4b4b4,
Te6edf3altitude Tff7b72=
Tff7b72if Tb4b4b4(Te6edf3LocationCompatTb4b4b4.Te6edf3hasMslAltitudeTb4b4b4(Te6edf3locationTb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3LocationCompatTb4b4b4.Te6edf3getMslAltitudeMetersTb4b4b4(Te6edf3locationTb4b4b4)Tb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)
Tb4b4b4} Tff7b72else Tb4b4b4{
Tff7b72null
Tb4b4b4}Tb4b4b4,
Te6edf3altitude_hae Tff7b72= Te6edf3locationTb4b4b4.Te6edf3altitudeTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3time Tff7b72= Tb4b4b4(Te6edf3locationTb4b4b4.Te6edf3timeTb4b4b4.Te6edf3millisecondsTb4b4b4.Te6edf3inWholeSecondsTb4b4b4)Tb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3ground_speed Tff7b72= Te6edf3locationTb4b4b4.Te6edf3speedTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3ground_track Tff7b72= Te6edf3locationTb4b4b4.Te6edf3bearingTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3location_source Tff7b72= Te6edf3ProtoPositionTb4b4b4.Te6edf3LocSourceTb4b4b4.Te6edf3LOC_EXTERNALTb4b4b4,
Tb4b4b4)Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4.Te6edf3launchInTb4b4b4(Te6edf3scopeTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffstopTb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3locationFlowTff7b72?.Te6edf3isActive Tff7b72=Tff7b72= Tff7b72trueTb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3i Tb4b4b4{ Ta5d6ff"Ta5d6ffStopping location requestsTa5d6ff" Tb4b4b4}
Te6edf3locationFlowTff7b72?.Te6edf3cancelTb4b4b4(Tb4b4b4)
Te6edf3locationFlow Tff7b72= Tff7b72null
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s